package com.muyu.controller;
import dev.langchain4j.model.ollama.OllamaChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 测试ollama本地模型控制层
 *
 * @author luguangkun
 * @version 1.0
 * @description: 测试ollama本地模型控制层
 * @date 2025/5/15 下午4:57
 **/
@RestController
@RequestMapping("/ai")
public class OllamaController {


    /**
     * 注入大模型
     */
    @Autowired
    private OllamaChatModel ollamaChatModel;

    /**
     * 本地部署大模型
     * @param userMessage 用户信息
     * @return 结果
     */
    @GetMapping("/ollama/{userMessage}")
    public String chat(@PathVariable("userMessage") String userMessage) {
        return ollamaChatModel.chat(userMessage);
    }
}
